package br.com.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.biblioteca.Book;
import br.com.biblioteca.BookList;


@WebServlet("/Catalog.do")
public class BookCatalogServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public BookCatalogServlet() {
        super();
       
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		PrintWriter out = response.getWriter();
		
		BookList lista = BookList.getSingleton();	
		List<Book> catalog = lista.getBooks();
		
		for (Book book : catalog) {
			out.println("<a href='/BBStyle/BookDetailsServlet?logica="+book.getIsbn()+"'>"+book.getTitle()+"</a><br/>");
		}
		
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
